package org.oos.dao;

import static org.oos.ApiUrlProvider.Users;

import org.oos.atom.UserFeed;
import org.oos.atom.UserFeedImpl;
import org.oos.atom.entries.UserEntry;
import org.oos.atom.entries.UserEntryImpl;
import org.oos.dao.lists.ReadOnlyDynamicList;

import com.google.api.client.http.GenericUrl;

public class UserDaoImpl extends AbstractDao<UserEntry, UserFeed<UserEntry>>
		implements UserDao {

	public UserDaoImpl() {
		super(UserFeedImpl.class, UserEntryImpl.class);
	}

	@Override
	protected GenericUrl getEntryUrl(UserEntry entry) {
		return getEntryUrl(entry.getSlug());
	}

	@Override
	protected GenericUrl getEntryUrl(String param) {
		return Users.getUrl(param);
	}

	@Override
	public GenericUrl getFeedUrl() {
		return Users.getUrl();
	}

	@Override
	protected GenericUrl getMediaUrl(UserEntry entry) {
		return getMediaUrl(entry.getSlug());
	}

	@Override
	protected GenericUrl getMediaUrl(String param) {
		return Users.getUrl(param, "avatar");
	}

	@SuppressWarnings("unchecked")
	@Override
	protected ReadOnlyDynamicList<UserEntry, UserFeed<UserEntry>> getList(UserFeed feed) {
		return new ReadOnlyDynamicList<UserEntry, UserFeed<UserEntry>>(this, feed);
	}

}
